import Mock, { Random } from 'mockjs';
import uuid from 'uuid/v4';
import { output, queryString } from '../help';
export function makeItem() {
  const types = ['realGoods', 'shopCoupon', 'tmallCoupon'];
  return {
    itemId: Random.increment(),
    title: Random.ctitle(10, 20),
    type: types[parseInt(Math.random() * 3)],
    img: Random.dataImage('80x80', '盛夏科技'),
    probability: (Random.integer(0, 100)),
    number: (Random.integer(10, 100)),
    content: (Random.sentence(50, 100)),
    updateTime: parseInt(Random.datetime('T')),
  };
}

Mock.mock(/mock.getItemDetail/, request => {
  const params = queryString(request.url);
  const { itemId } = params;
  return output({
    ...makeItem(),
    itemId: itemId,
  });
});

Mock.mock(/mock.addItem/, request => {
  const params = queryString(request.url);
  const { itemId } = params;
  return output({
    res: true,
  });
});



